package entity;

import java.awt.geom.Point2D;

import loading.ImageLoader;
import main.GameList;
import math.Vector2D;

/**
 * 
 * @author Greg G
 *
 * The DynamicEntity, a subclass of entity, provides methods and 
 * functionality for moving an entity
 */

public class DynamicEntity extends Entity
{
	private Vector2D velocity;
	
	public DynamicEntity(Point2D pos, GameList game, ImageLoader img)
	{
		super(pos, game, img);
		velocity = new Vector2D(0, 0);
	}
	//update the position based on velocity
	public void update(double duration)
	{
		super.update(duration);
		double x = getPosition().getX() + velocity.getXLen() * duration;
		double y = getPosition().getY() - velocity.getYLen() * duration;
		setPosition(x, y);
	}

	public void setVelocity(Vector2D vel)
	{
		velocity = vel;
	}
	public void setVelocity(double mag, double ang)
	{
		velocity = new Vector2D(mag, ang);
	}
	public Vector2D getVelocity()
	{
		return velocity;
	}
}
